<!DOCTYPE html>
<html lang="zh-CN" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Laravel 中 Faker库 | 静思田园</title>
    <meta name="description" content="时不时记录一点点">
    <meta name="generator" content="VitePress v1.5.0">
    <link rel="preload stylesheet" href="/assets/style.D1KHeDuB.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    <script type="module" src="/assets/chunks/metadata.d4b76d32.js"></script>
    <script type="module" src="/assets/app.Cqoht_Of.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/framework.trnLO_3_.js">
    <link rel="modulepreload" href="/assets/chunks/theme.BNMYWj-o.js">
    <link rel="modulepreload" href="/assets/chunks/katex.BZy9Y_85.js">
    <link rel="modulepreload" href="/assets/chunks/c4Diagram-3d4e48cf.rhyfUO3k.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-66a62f08.BvVfKYLl.js">
    <link rel="modulepreload" href="/assets/chunks/flowDiagram-v2-96b9c2cf.rYAPEXyw.js">
    <link rel="modulepreload" href="/assets/chunks/erDiagram-9861fffd.CQSbaoJM.js">
    <link rel="modulepreload" href="/assets/chunks/gitGraphDiagram-72cf32ee.CjLmC8RV.js">
    <link rel="modulepreload" href="/assets/chunks/ganttDiagram-c361ad54.R_V-FeK5.js">
    <link rel="modulepreload" href="/assets/chunks/infoDiagram-f8f76790.C-2Va9KZ.js">
    <link rel="modulepreload" href="/assets/chunks/pieDiagram-8a3498a8.B9ZVkD7K.js">
    <link rel="modulepreload" href="/assets/chunks/quadrantDiagram-120e2f19.BuonnDHi.js">
    <link rel="modulepreload" href="/assets/chunks/xychartDiagram-e933f94c.C_bIYaUn.js">
    <link rel="modulepreload" href="/assets/chunks/requirementDiagram-deff3bca.RFVzvdjl.js">
    <link rel="modulepreload" href="/assets/chunks/sequenceDiagram-704730f1.UZWxMlyq.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-70f12bd4.sipmPMFa.js">
    <link rel="modulepreload" href="/assets/chunks/classDiagram-v2-f2320105.CDkLxQ0T.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-587899a1.CD2ocVZB.js">
    <link rel="modulepreload" href="/assets/chunks/stateDiagram-v2-d93cdb3a.D0qUPm3J.js">
    <link rel="modulepreload" href="/assets/chunks/journeyDiagram-49397b02.CeUUZA2l.js">
    <link rel="modulepreload" href="/assets/chunks/flowchart-elk-definition-4a651766.DkdgpMTf.js">
    <link rel="modulepreload" href="/assets/chunks/timeline-definition-85554ec2.WL9yxus9.js">
    <link rel="modulepreload" href="/assets/chunks/mindmap-definition-fc14e90a.CWC2bxmB.js">
    <link rel="modulepreload" href="/assets/chunks/sankeyDiagram-04a897e0.BXj8OViR.js">
    <link rel="modulepreload" href="/assets/chunks/blockDiagram-38ab4fdb.CPVnJXk5.js">
    <link rel="modulepreload" href="/assets/chunks/virtual_mermaid-config.DDnGl6nM.js">
    <link rel="modulepreload" href="/assets/backend_PHP_Laravel_faker.md.VBurHkq4.lean.js">
    <meta name="application-name" content="VuePress">
    <meta name="apple-mobile-web-app-title" content="静思田园">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileColor" content="#3eaf7c">
    <meta name="theme-color" content="#646cff">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-1168a8e4><a class="title" href="/" data-v-1168a8e4><!--[--><!--]--><!--[--><img class="VPImage logo" src="/logo.png" alt data-v-8426fc1a><!--]--><span data-v-1168a8e4>静思田园</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索文档"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">搜索文档</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57></span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/network/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>网络工程师</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/frontend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>前端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/English/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>English</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/Scrupy/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>爬虫</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/backend/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>后端</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/bigdata/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>大数据</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/computer/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>计算机基础</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/database/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>数据库</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/docker/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>dorker</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/git/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Git</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/nodejs/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Node.js</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/python/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>Python</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/shell/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>shell</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/tools/" tabindex="0" data-v-dc692963 data-v-e56f3d57><!--[--><span data-v-e56f3d57>工具</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-cf11d7a2><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-cf11d7a2><span class="vpi-more-horizontal icon" data-v-cf11d7a2></span></button><div class="menu" data-v-cf11d7a2><div class="VPMenu" data-v-cf11d7a2 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>Appearance</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/loveagri" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><span class="vpi-social-github"></span></a><a class="VPSocialLink no-icon" href="https://gitee.com/loveagri" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-bd121fe5><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>码云</title><path d="M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296Z"/></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-17a5e62e><button data-v-17a5e62e>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 has-active" data-v-c40bc020 data-v-b7550ba0><div class="item" role="button" tabindex="0" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><h2 class="text" data-v-b7550ba0>Laravel</h2><!----></div><div class="items" data-v-b7550ba0><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/backend/PHP/Laravel/" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Laravel</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/backend/PHP/Laravel/faker.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Laravel 中 Faker库</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/backend/PHP/Laravel/problems.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>laravel常见问题</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>目录</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _backend_PHP_Laravel_faker" data-v-39a288b8><div><h1 id="laravel-中-faker库" tabindex="-1">Laravel 中 Faker库 <a class="header-anchor" href="#laravel-中-faker库" aria-label="Permalink to &quot;Laravel 中 Faker库&quot;">​</a></h1><p><a href="https://fakerphp.github.io/formatters/numbers-and-strings/" target="_blank" rel="noreferrer">官方文档</a></p><h2 id="no1、生成" tabindex="-1">No1、生成 <a class="header-anchor" href="#no1、生成" aria-label="Permalink to &quot;No1、生成&quot;">​</a></h2><h3 id="no-1基础生成-–-faker-provider-base" tabindex="-1">No.1基础生成 – Faker\Provider\Base <a class="header-anchor" href="#no-1基础生成-–-faker-provider-base" aria-label="Permalink to &quot;No.1基础生成 – Faker\Provider\Base&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$randomDigit</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">randomDigit</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成0-9之间的随机数</span></span>
<span class="line"><span style="color:#E06C75;">$randomDigitNotNull</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">randomDigitNotNull</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成1-9之间的随机数</span></span>
<span class="line"><span style="color:#E06C75;">$randomNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">randomNumber</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">5</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 生成5位整数，true表示严格模式，即只能5位</span></span>
<span class="line"><span style="color:#E06C75;">$randomFloat</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">randomFloat</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">2</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">10</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 生成浮点数，两位小数点，范围是0-10之间</span></span>
<span class="line"><span style="color:#E06C75;">$numberBetween</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">numberBetween</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">0</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">100</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 生成随机整数，范围是0-100之间</span></span>
<span class="line"><span style="color:#E06C75;">$randomLetter</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">randomLetter</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回a-z之间任意的一个小写字符</span></span>
<span class="line"><span style="color:#E06C75;">$randomElements</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">randomElements</span><span style="color:#ABB2BF;">([</span><span style="color:#98C379;">&#39;a&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;b&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;c&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;d&#39;</span><span style="color:#ABB2BF;">], </span><span style="color:#D19A66;">2</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回数组中的随机两个元素</span></span>
<span class="line"><span style="color:#E06C75;">$randomElement</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">randomElement</span><span style="color:#ABB2BF;">([</span><span style="color:#98C379;">&#39;aa&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;bb&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cc&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;dd&#39;</span><span style="color:#ABB2BF;">]); </span><span style="color:#7F848E;font-style:italic;">// 随机返回数组中的一个元素</span></span>
<span class="line"><span style="color:#E06C75;">$suffle</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">shuffle</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;hello, world&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 将字串中的字符打乱返回</span></span>
<span class="line"><span style="color:#E06C75;">$suffle</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">shuffle</span><span style="color:#ABB2BF;">([</span><span style="color:#98C379;">&#39;aa&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;bb&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cc&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;dd&#39;</span><span style="color:#ABB2BF;">]); </span><span style="color:#7F848E;font-style:italic;">// 将数组中的元素打乱返回</span></span>
<span class="line"><span style="color:#E06C75;">$numerify</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">numerify</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;Hello #####&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// #####替换为随机数字，输出类似：Hello 03501</span></span>
<span class="line"><span style="color:#E06C75;">$lexify</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">lexify</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;Hello ???&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// ???替换为3个随机小写字符，输出类似：Hello krg</span></span>
<span class="line"><span style="color:#E06C75;">$bothify</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">bothify</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;hello ##??&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// #替换为随机数字,?替换为随机小写字符.输出类似：hello 15cr</span></span>
<span class="line"><span style="color:#E06C75;">$asciify</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">asciify</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;hello *****&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// *替换为随机字符，输出类似：hello 5Ynt[</span></span>
<span class="line"><span style="color:#E06C75;">$regexify</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">regexify</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 根据正则表达式返回字串</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="no-2-生成文本-–-faker-provider-lorem" tabindex="-1">No.2 生成文本 – Faker\Provider\Lorem <a class="header-anchor" href="#no-2-生成文本-–-faker-provider-lorem" aria-label="Permalink to &quot;No.2 生成文本 – Faker\Provider\Lorem&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$word</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">word</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个单词</span></span>
<span class="line"><span style="color:#E06C75;">$words</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">words</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">3</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回3个单词，false表示返回一个数组；true表示返回一个字符串，单词之间用空格分开</span></span>
<span class="line"><span style="color:#E06C75;">$sentence</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">sentence</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">5</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个句子，false表示只能含有5个单词，true表示可以在5个单词左右</span></span>
<span class="line"><span style="color:#E06C75;">$sentences</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">sentences</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">3</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回3条句子，false表示返回一个数组，true表示将三条句子拼成一条返回</span></span>
<span class="line"><span style="color:#E06C75;">$paragraph</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">paragraph</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">3</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个段落，由3条句子组成。false表示只能有3条句子，true表示可以在3条句子左右</span></span>
<span class="line"><span style="color:#E06C75;">$paragraphs</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">paragraphs</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">4</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回4个段落。false表示返回一个数组，true表示将段落拼接在一起，并且用换行符分割</span></span>
<span class="line"><span style="color:#E06C75;">$text</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">text</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">200</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一段文本，最多只能含有200个字符</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="no-3-人名生成-–-faker-provider-en-us-person" tabindex="-1">No.3 人名生成 – Faker\Provider\en_US\Person <a class="header-anchor" href="#no-3-人名生成-–-faker-provider-en-us-person" aria-label="Permalink to &quot;No.3 人名生成 – Faker\Provider\en_US\Person&quot;">​</a></h3><div class="language-cpp line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#ABB2BF;">$title </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">title</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;female&#39;</span><span style="color:#ABB2BF;">);</span><span style="color:#7F848E;font-style:italic;"> // 参数：title($gender = null|&#39;male&#39;|&#39;female&#39;) .返回称呼。例如：Mrs.|Prof.|Dr.</span></span>
<span class="line"><span style="color:#ABB2BF;">$titleMale </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">titleMale</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // 返回男性称呼</span></span>
<span class="line"><span style="color:#ABB2BF;">$titleFemale </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">titleFemale</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // 返回女性称呼</span></span>
<span class="line"><span style="color:#ABB2BF;">$name </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">name</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;female&#39;</span><span style="color:#ABB2BF;">);</span><span style="color:#7F848E;font-style:italic;"> // 参数：name($gender = null|&#39;male&#39;|&#39;female&#39;) .返回姓名</span></span>
<span class="line"><span style="color:#ABB2BF;">$firstName </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">firstName</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;female&#39;</span><span style="color:#ABB2BF;">);</span><span style="color:#7F848E;font-style:italic;"> // 参数：firstName($gender = null|&#39;male&#39;|&#39;female&#39;) .返回名</span></span>
<span class="line"><span style="color:#ABB2BF;">$firstNameMale </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">firstNameMale</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // 男性名字</span></span>
<span class="line"><span style="color:#ABB2BF;">$firstNameFemale </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">firstNameFemale</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // 女性名字</span></span>
<span class="line"><span style="color:#ABB2BF;">$lastName </span><span style="color:#C678DD;">=</span><span style="color:#ABB2BF;"> $</span><span style="color:#E5C07B;">faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">lastName</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;"> // 姓</span></span>
<span class="line"><span style="color:#D19A66;">12345678</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="no-4-地址生成-–-faker-provider-en-us-address" tabindex="-1">No.4 地址生成 – Faker\Provider\en_US\Address <a class="header-anchor" href="#no-4-地址生成-–-faker-provider-en-us-address" aria-label="Permalink to &quot;No.4 地址生成 – Faker\Provider\en_US\Address&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$cityPrefix</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">cityPrefix</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 城市前缀.如：Lake</span></span>
<span class="line"><span style="color:#E06C75;">$secondaryAddress</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">secondaryAddress</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 二级地址.如：Suite 061</span></span>
<span class="line"><span style="color:#E06C75;">$state</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">state</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 州、省（如：Colorado、四川省）</span></span>
<span class="line"><span style="color:#E06C75;">$stateAbbr</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">stateAbbr</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 省份简称.如：晋、蒙、浙、冀</span></span>
<span class="line"><span style="color:#E06C75;">$citySuffix</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">citySuffix</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 城市后缀.如：side、land、port、Ville</span></span>
<span class="line"><span style="color:#E06C75;">$streetSuffix</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">streetSuffix</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 街道后缀.如：Ramp、Plains</span></span>
<span class="line"><span style="color:#E06C75;">$buildingNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">buildingNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 建筑物编号</span></span>
<span class="line"><span style="color:#E06C75;">$city</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">city</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 城市</span></span>
<span class="line"><span style="color:#E06C75;">$streetName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">streetName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 街道名称</span></span>
<span class="line"><span style="color:#E06C75;">$streetAddress</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">streetAddress</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 街道地址</span></span>
<span class="line"><span style="color:#E06C75;">$postcode</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">postcode</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 邮政编码</span></span>
<span class="line"><span style="color:#E06C75;">$address</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">address</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 地址（城市+区）</span></span>
<span class="line"><span style="color:#E06C75;">$country</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">country</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 国家</span></span>
<span class="line"><span style="color:#E06C75;">$latitude</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">latitude</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 纬度 latitude($min = -90, $max = 90)</span></span>
<span class="line"><span style="color:#E06C75;">$longitude</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">longitude</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 经度 longitude($min = -180, $max = 180)</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="no-5-电话号码生成-–-faker-provider-en-us-phonenumber" tabindex="-1">No.5 电话号码生成 – Faker\Provider\en_US\PhoneNumber <a class="header-anchor" href="#no-5-电话号码生成-–-faker-provider-en-us-phonenumber" aria-label="Permalink to &quot;No.5 电话号码生成 – Faker\Provider\en_US\PhoneNumber&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$phoneNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">phoneNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 手机号码</span></span>
<span class="line"><span style="color:#E06C75;">$tollFreePhoneNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">tollFreePhoneNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 免费电话号码</span></span>
<span class="line"><span style="color:#E06C75;">$e164PhoneNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">e164PhoneNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// e164电话号码</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="no-6-公司资料生成-–-faker-provider-en-us-company" tabindex="-1">No.6 公司资料生成 – Faker\Provider\en_US\Company <a class="header-anchor" href="#no-6-公司资料生成-–-faker-provider-en-us-company" aria-label="Permalink to &quot;No.6 公司资料生成 – Faker\Provider\en_US\Company&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$catchPhrase</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">catchPhrase</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 公司口号</span></span>
<span class="line"><span style="color:#E06C75;">$bs</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">bs</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 结构</span></span>
<span class="line"><span style="color:#E06C75;">$company</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">company</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 公司名称</span></span>
<span class="line"><span style="color:#E06C75;">$companySuffix</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">companySuffix</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 公司名称后缀</span></span>
<span class="line"><span style="color:#E06C75;">$jobTitle</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">jobTitle</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 职称</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h3 id="no-7-文本生成-–-faker-provider-en-us-text" tabindex="-1">No.7 文本生成 – Faker\Provider\en_US\Text <a class="header-anchor" href="#no-7-文本生成-–-faker-provider-en-us-text" aria-label="Permalink to &quot;No.7 文本生成 – Faker\Provider\en_US\Text&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$realText</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">realText</span><span style="color:#ABB2BF;">(); </span><span style="color:#7F848E;font-style:italic;">// 一段叙事文本</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="no-8-时间生成-–-faker-provider-datetime" tabindex="-1">No.8 时间生成 – Faker\Provider\DateTime <a class="header-anchor" href="#no-8-时间生成-–-faker-provider-datetime" aria-label="Permalink to &quot;No.8 时间生成 – Faker\Provider\DateTime&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$unixTime</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">unixTime</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回随机时间戳</span></span>
<span class="line"><span style="color:#E06C75;">$unixTime</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">unixTime</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回随机时间戳 可选最后截止时间</span></span>
<span class="line"><span style="color:#E06C75;">$dateTime</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTime</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTime</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTime</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的DateTime对象，可选择最后截止时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeAD</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTimeAD</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeAD</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeAD</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的DateTime对象，可选择最后截止时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$iso8601</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">iso8601</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的字符串形式的时间</span></span>
<span class="line"><span style="color:#E06C75;">$iso8601</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">iso8601</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的字符串形式的时间,可选择最后截止时间</span></span>
<span class="line"><span style="color:#E06C75;">$date</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">date</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&quot;Y-m-d H:i:s&quot;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 指定格式返回时间,可选择最后截止时间</span></span>
<span class="line"><span style="color:#E06C75;">$time</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">time</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;Y-m-d H:i:s&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// (同上)指定格式返回时间,可选择最后截止时间</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeBetween</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeBetween</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;2019-01-01&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回指定时间区间的DateTime对象，可选时区</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeInInterval</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeInInterval</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;-5 years&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;+5 days&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回指定时间区间的DateTime对象，可选时区(第一个参数：开始时间，第二个参数：时间范围)</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisCentury</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTimeThisCentury</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个本世纪内的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisCentury</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeThisCentury</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;1950-01-01&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个本世纪内的DateTime对象.指定截止时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisDecade</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTimeThisDecade</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个前十年内的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisDecade</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeThisDecade</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;2015-01-01&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个前十年内的DateTime对象.指定允许的最后时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisYear</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTimeThisYear</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个前一年内的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisYear</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeThisYear</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;now&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个前一年内的DateTime对象.指定允许的最后时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisMonth</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dateTimeThisMonth</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个前一个月内的DateTime对象</span></span>
<span class="line"><span style="color:#E06C75;">$dateTimeThisMonth</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">dateTimeThisMonth</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;-15 days&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;PRC&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回一个前一个月内的DateTime对象.指定允许的最后时间和时区</span></span>
<span class="line"><span style="color:#E06C75;">$amPm</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">amPm</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 上午/下午</span></span>
<span class="line"><span style="color:#E06C75;">$dayOfMonth</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dayOfMonth</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回几号</span></span>
<span class="line"><span style="color:#E06C75;">$dayOfWeek</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">dayOfWeek</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回星期几</span></span>
<span class="line"><span style="color:#E06C75;">$month</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">month</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回月份</span></span>
<span class="line"><span style="color:#E06C75;">$monthName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">monthName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回月份名称</span></span>
<span class="line"><span style="color:#E06C75;">$year</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">year</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回年份</span></span>
<span class="line"><span style="color:#E06C75;">$year</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">year</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;2000-01-01&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// 返回年份.可指定最后截止日期</span></span>
<span class="line"><span style="color:#E06C75;">$timezone</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">timezone</span><span style="color:#ABB2BF;">;</span><span style="color:#7F848E;font-style:italic;">//返回时区</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br></div></div><h3 id="no-9-互联网资料生成-邮箱-账户密码-ip-域名等-–-faker-provider-internet" tabindex="-1">No.9 互联网资料生成（邮箱，账户密码，ip，域名等） – Faker\Provider\Internet <a class="header-anchor" href="#no-9-互联网资料生成-邮箱-账户密码-ip-域名等-–-faker-provider-internet" aria-label="Permalink to &quot;No.9 互联网资料生成（邮箱，账户密码，ip，域名等） – Faker\Provider\Internet&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$email</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">email</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机邮箱</span></span>
<span class="line"><span style="color:#E06C75;">$safeEmail</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">safeEmail</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个以@example.com结尾的安全邮箱</span></span>
<span class="line"><span style="color:#E06C75;">$freeEmail</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">freeEmail</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机邮箱</span></span>
<span class="line"><span style="color:#E06C75;">$companyEmail</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">companyEmail</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回企业邮箱（中文语言包下不可用）</span></span>
<span class="line"><span style="color:#E06C75;">$freeEmailDomain</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">freeEmailDomain</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个邮件域名</span></span>
<span class="line"><span style="color:#E06C75;">$safeEmailDomain</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">safeEmailDomain</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回安全的邮件域名</span></span>
<span class="line"><span style="color:#E06C75;">$userName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">userName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 用户名</span></span>
<span class="line"><span style="color:#E06C75;">$password</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">password</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 密码</span></span>
<span class="line"><span style="color:#E06C75;">$domainName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">domainName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 域名（中文语言包下不可用）</span></span>
<span class="line"><span style="color:#E06C75;">$domainWord</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">domainWord</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 不带后缀的域名（中文语言包下不可用）</span></span>
<span class="line"><span style="color:#E06C75;">$tld</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">tld</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 域名后缀：如com、org（中文语言包下不可用）</span></span>
<span class="line"><span style="color:#E06C75;">$url</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">url</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机url（中文语言包下不可用）</span></span>
<span class="line"><span style="color:#E06C75;">$slug</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">slug</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个别名地址</span></span>
<span class="line"><span style="color:#E06C75;">$ipv4</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">ipv4</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个ipv4地址</span></span>
<span class="line"><span style="color:#E06C75;">$ipv6</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">ipv6</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个ipv6地址</span></span>
<span class="line"><span style="color:#E06C75;">$localIpv4</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">localIpv4</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回本地的ipv4地址</span></span>
<span class="line"><span style="color:#E06C75;">$macAddress</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">macAddress</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// mac地址</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><h3 id="no-10-用户代理信息生成-–-faker-provider-useragent" tabindex="-1">No.10 用户代理信息生成 – Faker\Provider\UserAgent <a class="header-anchor" href="#no-10-用户代理信息生成-–-faker-provider-useragent" aria-label="Permalink to &quot;No.10 用户代理信息生成 – Faker\Provider\UserAgent&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$userAgent</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">userAgent</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个随机的用户代理信息</span></span>
<span class="line"><span style="color:#E06C75;">$chrome</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">chrome</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个chrome浏览器的用户代理信息</span></span>
<span class="line"><span style="color:#E06C75;">$firefox</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">firefox</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个firefox浏览器的用户代理信息</span></span>
<span class="line"><span style="color:#E06C75;">$safari</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">safari</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个safari浏览器的用户代理信息</span></span>
<span class="line"><span style="color:#E06C75;">$opera</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">opera</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个opera浏览器的用户代理信息</span></span>
<span class="line"><span style="color:#E06C75;">$internetExplorer</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">internetExplorer</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个internetExplorer浏览器的用户代理信息</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="no-11-支付信息生成-拥有的银行卡号-银行信息等-–-faker-provider-payment" tabindex="-1">No.11 支付信息生成（拥有的银行卡号，银行信息等） – Faker\Provider\Payment <a class="header-anchor" href="#no-11-支付信息生成-拥有的银行卡号-银行信息等-–-faker-provider-payment" aria-label="Permalink to &quot;No.11 支付信息生成（拥有的银行卡号，银行信息等） – Faker\Provider\Payment&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$creditCardType</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">creditCardType</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 信用卡类型</span></span>
<span class="line"><span style="color:#E06C75;">$creditCardNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">creditCardNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 信用卡号</span></span>
<span class="line"><span style="color:#E06C75;">$creditCardExpirationDate</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">creditCardExpirationDate</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 信用卡到期日 (DateTime对象)</span></span>
<span class="line"><span style="color:#E06C75;">$creditCardExpirationDateString</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">creditCardExpirationDateString</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 信用卡到期日期字符串</span></span>
<span class="line"><span style="color:#E06C75;">$creditCardDetails</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">creditCardDetails</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 信用卡详情（数组）</span></span>
<span class="line"><span style="color:#E06C75;">$swiftBicNumber</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">swiftBicNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 返回一个国际编号</span></span>
<span class="line"><span style="color:#E06C75;">$iban</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">iban</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 国际银行账户</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="no-12-颜色值生成-–-faker-provider-color" tabindex="-1">No.12 颜色值生成 – Faker\Provider\Color <a class="header-anchor" href="#no-12-颜色值生成-–-faker-provider-color" aria-label="Permalink to &quot;No.12 颜色值生成 – Faker\Provider\Color&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$hexcolor</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">hexcolor</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 十六进制的随机色：&#39;#fa3cc2&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$rgbcolor</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">rgbcolor</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// RGB格式的随机色（字串形式）：&#39;0,255,122&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$rgbColorAsArray</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">rgbColorAsArray</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// RGB格式的随机色（数组形式）：array(0,255,122)</span></span>
<span class="line"><span style="color:#E06C75;">$rgbCssColor</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">rgbCssColor</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// RGB格式的随机色的css表示：&#39;rgb(0,255,122)&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$safeColorName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">safeColorName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 一个安全的随机色名称</span></span>
<span class="line"><span style="color:#E06C75;">$colorName</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">colorName</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 随机色名称</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="no-13-文件信息生成-–-faker-provider-file" tabindex="-1">No.13 文件信息生成 – Faker\Provider\File <a class="header-anchor" href="#no-13-文件信息生成-–-faker-provider-file" aria-label="Permalink to &quot;No.13 文件信息生成 – Faker\Provider\File&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$fileExtension</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">fileExtension</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 文件后缀</span></span>
<span class="line"><span style="color:#E06C75;">$mimeType</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">mimeType</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// mime类型</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 将一个随机文件从源文件复制到目标目录，并返回fullpath</span></span>
<span class="line"><span style="color:#E06C75;">$file</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">file</span><span style="color:#ABB2BF;">(</span><span style="color:#E06C75;">$sourceDir</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &#39;./up1&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#E06C75;">$targetDir</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &#39;./up2&#39;</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 将一个随机文件从源文件复制到目标目录，并返回basename</span></span>
<span class="line"><span style="color:#E06C75;">$file</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">file</span><span style="color:#ABB2BF;">(</span><span style="color:#E06C75;">$sourceDir</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &#39;./up1&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#E06C75;">$targetDir</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &#39;./up2&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="no-14-图片生成-–-faker-provider-image" tabindex="-1">No.14 图片生成 – Faker\Provider\Image <a class="header-anchor" href="#no-14-图片生成-–-faker-provider-image" aria-label="Permalink to &quot;No.14 图片生成 – Faker\Provider\Image&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$imageUrl</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">imageUrl</span><span style="color:#ABB2BF;">(); </span><span style="color:#7F848E;font-style:italic;">// https://lorempixel.com/640/480/?93028</span></span>
<span class="line"><span style="color:#E06C75;">$imageUrl</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">imageUrl</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// https://lorempixel.com/320/320/cats/?68416</span></span>
<span class="line"><span style="color:#E06C75;">$imageUrl</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">imageUrl</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;Faker&#39;</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// https://lorempixel.com/320/320/cats/Faker/?68118</span></span>
<span class="line"><span style="color:#E06C75;">$imageUrl</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">imageUrl</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;Faker&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">); </span><span style="color:#7F848E;font-style:italic;">// https://lorempixel.com/gray/320/320/cats/Faker/?28732</span></span>
<span class="line"></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 生成图片并保存到本地 &#39;/tmp/13b73edae8443990be1aa8f1a483bc27.jpg&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$image</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">image</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;./tmp&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 设置类别并生成图片保存到本地  &#39;tmp/13b73edae8443990be1aa8f1a483bc27.jpg&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$image</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">image</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;./tmp&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 设置类别并生成图片保存到本地，只返回文件名 &#39;13b73edae8443990be1aa8f1a483bc27.jpg&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$image</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">image</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;./tmp&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 生成没有随机化的图像</span></span>
<span class="line"><span style="color:#E06C75;">$image</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">image</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;./tmp&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">false</span><span style="color:#ABB2BF;">);</span></span>
<span class="line"><span style="color:#7F848E;font-style:italic;">// 生成图片并加上水印字体  &#39;tmp/13b73edae8443990be1aa8f1a483bc27.jpg&#39;</span></span>
<span class="line"><span style="color:#E06C75;">$image</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">image</span><span style="color:#ABB2BF;">(</span><span style="color:#98C379;">&#39;./tmp&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">320</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;cats&#39;</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">true</span><span style="color:#ABB2BF;">, </span><span style="color:#98C379;">&#39;Faker&#39;</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="no-15-uuid生成-–-faker-provider-uuid" tabindex="-1">No.15 Uuid生成 – Faker\Provider\Uuid <a class="header-anchor" href="#no-15-uuid生成-–-faker-provider-uuid" aria-label="Permalink to &quot;No.15 Uuid生成 – Faker\Provider\Uuid&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$uuid</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">uuid</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个uuid</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="no-16-条形码生产-–-faker-provider-barcode" tabindex="-1">No.16 条形码生产 – Faker\Provider\Barcode <a class="header-anchor" href="#no-16-条形码生产-–-faker-provider-barcode" aria-label="Permalink to &quot;No.16 条形码生产 – Faker\Provider\Barcode&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$ean13</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">ean13</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 8105964964473</span></span>
<span class="line"><span style="color:#E06C75;">$ean8</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">ean8</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 05994441</span></span>
<span class="line"><span style="color:#E06C75;">$isbn13</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">isbn13</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 9780971408739</span></span>
<span class="line"><span style="color:#E06C75;">$isbn10</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">isbn10</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 0813387299</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="no-17-其余生成-–-faker-provider-miscellaneous" tabindex="-1">No.17 其余生成 – Faker\Provider\Miscellaneous <a class="header-anchor" href="#no-17-其余生成-–-faker-provider-miscellaneous" aria-label="Permalink to &quot;No.17 其余生成 – Faker\Provider\Miscellaneous&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#E06C75;">$boolean</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">boolean</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个布尔值</span></span>
<span class="line"><span style="color:#E06C75;">$md5</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">md5</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个md5码</span></span>
<span class="line"><span style="color:#E06C75;">$sha1</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">sha1</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个sha1</span></span>
<span class="line"><span style="color:#E06C75;">$sha256</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">sha256</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个sha256</span></span>
<span class="line"><span style="color:#E06C75;">$locale</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">locale</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个地区编码：如zh_CN</span></span>
<span class="line"><span style="color:#E06C75;">$countryCode</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">countryCode</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个国家编码。如：UK</span></span>
<span class="line"><span style="color:#E06C75;">$languageCode</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">languageCode</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个语言编码.如：en</span></span>
<span class="line"><span style="color:#E06C75;">$currencyCode</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">currencyCode</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个货币代码.如：EUR</span></span>
<span class="line"><span style="color:#E06C75;">$emoji</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">emoji</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// 生成一个emoji表情</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="no-18-偏向生成-–-faker-provider-biased" tabindex="-1">No.18 偏向生成 – Faker\Provider\Biased <a class="header-anchor" href="#no-18-偏向生成-–-faker-provider-biased" aria-label="Permalink to &quot;No.18 偏向生成 – Faker\Provider\Biased&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// 得到10到20之间的随机数，并且更多机会接近20</span></span>
<span class="line"><span style="color:#E06C75;">$biasedNumberBetween</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">biasedNumberBetween</span><span style="color:#ABB2BF;">(</span><span style="color:#E06C75;">$min</span><span style="color:#56B6C2;"> =</span><span style="color:#D19A66;"> 10</span><span style="color:#ABB2BF;">, </span><span style="color:#E06C75;">$max</span><span style="color:#56B6C2;"> =</span><span style="color:#D19A66;"> 20</span><span style="color:#ABB2BF;">, </span><span style="color:#E06C75;">$function</span><span style="color:#56B6C2;"> =</span><span style="color:#98C379;"> &#39;sqrt&#39;</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="no-19-html-文档-生成-–-faker-provider-htmllorem" tabindex="-1">No.19 html 文档 生成 – Faker\Provider\HtmlLorem <a class="header-anchor" href="#no-19-html-文档-生成-–-faker-provider-htmllorem" aria-label="Permalink to &quot;No.19 html 文档 生成 – Faker\Provider\HtmlLorem&quot;">​</a></h3><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// 生成不超过2级深度的HTML文档，并且在任何级别上都不超过3个元素。</span></span>
<span class="line"><span style="color:#E06C75;">$randomHtml</span><span style="color:#56B6C2;"> =</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#61AFEF;">randomHtml</span><span style="color:#ABB2BF;">(</span><span style="color:#D19A66;">2</span><span style="color:#ABB2BF;">, </span><span style="color:#D19A66;">3</span><span style="color:#ABB2BF;">);</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="no2、特定于语言的格式器-language-specific-formatters" tabindex="-1">No2、特定于语言的格式器 Language specific formatters <a class="header-anchor" href="#no2、特定于语言的格式器-language-specific-formatters" aria-label="Permalink to &quot;No2、特定于语言的格式器 Language specific formatters&quot;">​</a></h2><p>Faker\Provider\zh_CN\Payment</p><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// 生成一个随机的银行名称(基于真实的中国银行的列表)</span></span>
<span class="line"><span style="color:#56B6C2;">echo</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">bank</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// &#39;中国建设银行&#39;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>Faker\Provider\zh_TW\Person</p><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// 生成一个随机的个人识别号码（基于TW Id Card 证生成规则）</span></span>
<span class="line"><span style="color:#56B6C2;">echo</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">personalIdentityNumber</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">// A223456789</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>Faker\Provider\zh_TW\Company</p><div class="language-php line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">php</span><pre class="shiki one-dark-pro vp-code" style="background-color:#282c34;color:#abb2bf;" tabindex="0"><code><span class="line"><span style="color:#7F848E;font-style:italic;">// 生成一个随机的增值税/公司税号（基于TW Company 税号生成规则）</span></span>
<span class="line"><span style="color:#56B6C2;">echo</span><span style="color:#E06C75;"> $faker</span><span style="color:#ABB2BF;">-&gt;</span><span style="color:#E06C75;">VAT</span><span style="color:#ABB2BF;">; </span><span style="color:#7F848E;font-style:italic;">//23456789</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><div class="edit-info" data-v-e257564d><!----><div class="last-updated" data-v-e257564d><p class="VPLastUpdated" data-v-e257564d data-v-e98dd255>最后更新: <time datetime="2024-12-30T14:20:32.000Z" data-v-e98dd255></time></p></div></div><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/backend/PHP/Laravel/" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>上一篇</span><span class="title" data-v-e257564d>Laravel</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/backend/PHP/Laravel/problems.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>下一篇</span><span class="title" data-v-e257564d>laravel常见问题</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    
    
  </body>
</html>